<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        window.onload = function (ev) {
            var h1 = document.getElementById("h1");
            var i = 1;
            function test() {
                if (i == 1) {
                    h1.innerHTML = 'world';
                    i = 2;
                }else {
                    h1.innerHTML = 'hello';
                    i = 1;
                }
            }
            setInterval(test,1000);
        }
    </script>
</head>
<body>
    <h1 id="h1">hello</h1>
</body>
</html>